package com.csdj.wenjun.utils;

import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;

import java.io.IOException;

public class TuPianJianChai {
    public static void jianJie(String img){
        String imgPath=img.substring(33,img.length());
        imgPath="D:/NZrengli/img/"+imgPath;
        System.out.println(imgPath);

//        //原始图片路径
//        String imgPath = "D:/NZrengli/img/aa.png";
//        //压缩图片路径
        String smallImgPath1 = imgPath.replace(".", "_small1.");
        String smallImgPath2 = imgPath.replace(".", "_small2.");
        String smallImgPath3 = imgPath.replace(".", "_small3.");
        String smallImgPath4 = imgPath.replace(".", "_small4.");
        String smallImgPath5 = imgPath.replace(".", "_small5.");
        String smallImgPath6 = imgPath.replace(".", "_small6.");
        String smallImgPath7 = imgPath.replace(".", "_small7.");
        String smallImgPath8 = imgPath.replace(".", "_small8.");
        String smallImgPath9 = imgPath.replace(".", "_small9.");
        try {
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.TOP_LEFT,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath1);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.TOP_CENTER,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath2);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.TOP_RIGHT,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath3);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.CENTER_LEFT,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath4);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.CENTER,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath5);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.CENTER_RIGHT,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath6);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.BOTTOM_LEFT,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath7);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.BOTTOM_CENTER,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath8);
            Thumbnails.of(imgPath)
                    .sourceRegion(Positions.BOTTOM_RIGHT,1008,1344)
                    .size(200,200)
                    .keepAspectRatio(false)
                    .outputQuality(1)
                    .toFile(smallImgPath9);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
